package com.fare.taluo.application.impl.report;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.report.csair.ZhairReportApplication;
import com.fare.taluo.core.domain.analyse.report.ZhairReportEntity;
import com.fare.taluo.util.DateUtils;
import com.fare.taluo.vo.report.ZhairReportEntityVO;
@Transactional
@Scope("singleton")
@Service("zhairReportApplication")
public class ZhairReportApplicationImpl implements ZhairReportApplication{
	public List<ZhairReportEntityVO> findZhairReportEntityByCondition(
			String hbaseKey, String fromCityCode, String toCityCode,
			 String flightDate){
		ZhairReportEntity entity = new ZhairReportEntity();
		List<ZhairReportEntity> entityList = entity.findZhairReportEntityByCondition(hbaseKey, fromCityCode, toCityCode, flightDate);	
		return this.convert2ListVO(entityList);
	}
	public List<ZhairReportEntityVO> convert2ListVO(List<ZhairReportEntity> entityList){
		List<ZhairReportEntityVO> voList = new ArrayList<ZhairReportEntityVO>();	
		for (ZhairReportEntity zhairReportEntity : entityList) {
			voList.add(this.convert2VO(zhairReportEntity));
		}
		return voList;
	}
	
	public ZhairReportEntityVO convert2VO(ZhairReportEntity entity){
		ZhairReportEntityVO vo = new ZhairReportEntityVO();
		vo.setChannelKey(entity.getChannelKey());
		vo.setChannelPrice(entity.getChannelPrice());
		vo.setCreattime(entity.getCreattime());
		vo.setFlightDate(entity.getFlightDate());
		vo.setFlightNo(entity.getFlightNo());
		vo.setFromCity(entity.getFromCity());
		vo.setFromCityName(entity.getFromCityName());
		vo.setHbaseKey(entity.getHbaseKey());
		vo.setPrice(entity.getPrice());
		vo.setReportDate(entity.getReportDate());
		vo.setSpread(entity.getSpread());
		vo.setSpreadAmount(entity.getSpreadAmount());
		vo.setStartTime(entity.getStartTime());
		vo.setToCity(entity.getToCity());
		vo.setToCityName(entity.getToCityName());
		vo.setFlightTime(DateUtils.formatDay(entity.getStartTime(), "yyyy-MM-dd HH:mm:ss").substring(11, 16));
		return vo;
	}
	
	
}
